package com.cll.learn.rabbitmq.controller;

import com.cll.learn.rabbitmq.util.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述信息:
 *
 * @author CLL
 * @version 1.0
 * @date 2021/2/3 12:55
 */
@Controller
@RequestMapping(value = "/sys/test")
public class TestController {

    private static final Logger logger = LoggerFactory.getLogger(TestController.class);

    @ResponseBody
    @GetMapping(value = "/helloWorld")
    public AjaxResult<String> helloWorld(String username){
        logger.info("===>>> 接收参数 = {}", username);
        try {
            return new AjaxResult<>(200, "响应成功", "接收和响应数据正常");
        } catch (Exception e) {
            logger.error("****** 返回响应抛出异常");
            return new AjaxResult<>(500, "系统错误");
        }
    }

    @GetMapping(value = "/page")
    public String page(){
        logger.info("===>>> 访问测试页面");
        return "test";
    }
}